package com.aaa.java14;

import java.io.Serializable;
import java.util.Objects;

/**
 * @author ：Teacher陈（86521760@qq.com）
 * @date ：Created in 2022/7/18 8:57
 * @description：老师类
 * @modified By：
 * @version: 1.0
 */
public class Teacher  implements Serializable  /*implements  Comparable<Teacher> */{
    private  int  id;
    private String name;
    private  int sal;

    public Teacher() {
    }

    public Teacher(int id, String name, int sal) {
        this.id = id;
        this.name = name;
        this.sal = sal;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getSal() {
        return sal;
    }

    public void setSal(int sal) {
        this.sal = sal;
    }

    @Override
    public String toString() {
        return "Teacher{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", sal=" + sal +
                '}';
    }

    /*@Override
    public int compareTo(Teacher o) {
        if(this.sal>o.getSal()){
            return 1;
        }
        if(this.sal<o.getSal()){
            return -1;
        }
        return 0;
    }*/

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Teacher teacher = (Teacher) o;
        return id == teacher.id;
    }

    @Override
    public int hashCode() {
        System.out.println("hashcode被调用了");
        return Objects.hash(id);
    }
}
